package top.iforum.bbs.modules.sys.service.impl;

import top.iforum.bbs.modules.sys.controller.RoleController;
import top.iforum.bbs.modules.sys.entity.Role;
import top.iforum.bbs.modules.sys.entity.Teacher;
import top.iforum.bbs.modules.sys.entity.User;
import top.iforum.bbs.modules.sys.service.IRoleService;
import top.iforum.bbs.modules.sys.service.ITeacherService;
import top.iforum.common.mybatis.mvc.wrapper.EntityWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 张娜
 * @since 1.0
 */
//@Transactional
@Service("teacherService")
public class TeacherServiceImpl extends UserServiceImpl implements ITeacherService {

    @Autowired
    IRoleService roleService;

    @Override
    public Iterable<? extends Teacher> selectAllTeacher() {
        EntityWrapper<User> entityWrapper = new EntityWrapper<>(User.class);
        List<Role> teacherRoles = roleService.selectByMap(RoleController.TEACHER_NAME_QUERY_CONDITION_MAP);
        entityWrapper.eq("role_id",teacherRoles.get(0).getId());
        return baseMapper.selectTeacherList(entityWrapper);
    }
}
